import type { Request, Response } from 'express';

// mock data
const radarOriginData = [
    {
        name: '个人',
        ref: 10,
        koubei: 8,
        output: 4,
        contribute: 5,
        hot: 7,
    },
    {
        name: '团队',
        ref: 3,
        koubei: 9,
        output: 6,
        contribute: 3,
        hot: 1,
    },
    {
        name: '部门',
        ref: 4,
        koubei: 1,
        output: 6,
        contribute: 5,
        hot: 7,
    },
];

const radarData: any[] = [];
const radarTitleMap = {
    ref: '引用',
    koubei: '口碑',
    output: '产量',
    contribute: '贡献',
    hot: '热度',
};
radarOriginData.forEach((item) => {
    Object.keys(item).forEach((key) => {
        if (key !== 'name') {
            radarData.push({
                name: item.name,
                label: radarTitleMap[key],
                value: item[key],
            });
        }
    });
});

const getChartData = (_: Request, res: Response) => {
    res.json({
        data: radarData,
    });
};

export default {
    'GET /mockApi/fake_radar_chart_data': getChartData,
    'GET /mockApi/fake_line_chart_data': (_: Request, res: Response) => {
        return res.json({
            data: [
                {
                    date: '2018/8/1',
                    type: '下载',
                    value: 4623,
                },
                {
                    date: '2018/8/1',
                    type: '访问',
                    value: 2208,
                },
                {
                    date: '2018/8/1',
                    type: '申请',
                    value: 182,
                },
                {
                    date: '2018/8/2',
                    type: '下载',
                    value: 6145,
                },
                {
                    date: '2018/8/2',
                    type: '访问',
                    value: 2016,
                },
                {
                    date: '2018/8/2',
                    type: '申请',
                    value: 257,
                },
                {
                    date: '2018/8/3',
                    type: '下载',
                    value: 508,
                },
                {
                    date: '2018/8/3',
                    type: '访问',
                    value: 2916,
                },
                {
                    date: '2018/8/3',
                    type: '申请',
                    value: 289,
                },
                {
                    date: '2018/8/4',
                    type: '下载',
                    value: 6268,
                },
                {
                    date: '2018/8/4',
                    type: '访问',
                    value: 4512,
                },
                {
                    date: '2018/8/4',
                    type: '申请',
                    value: 428,
                },
                {
                    date: '2018/8/5',
                    type: '下载',
                    value: 6411,
                },
                {
                    date: '2018/8/5',
                    type: '访问',
                    value: 8281,
                },
                {
                    date: '2018/8/5',
                    type: '申请',
                    value: 619,
                },
                {
                    date: '2018/8/6',
                    type: '下载',
                    value: 1890,
                },
                {
                    date: '2018/8/6',
                    type: '访问',
                    value: 2008,
                },
                {
                    date: '2018/8/6',
                    type: '申请',
                    value: 87,
                },
                {
                    date: '2018/8/7',
                    type: '下载',
                    value: 4251,
                },
                {
                    date: '2018/8/7',
                    type: '访问',
                    value: 1963,
                },
                {
                    date: '2018/8/7',
                    type: '申请',
                    value: 706,
                },
                {
                    date: '2018/8/8',
                    type: '下载',
                    value: 2978,
                },
                {
                    date: '2018/8/8',
                    type: '访问',
                    value: 2367,
                },
                {
                    date: '2018/8/8',
                    type: '申请',
                    value: 387,
                },
                {
                    date: '2018/8/9',
                    type: '下载',
                    value: 3880,
                },
                {
                    date: '2018/8/9',
                    type: '访问',
                    value: 2956,
                },
                {
                    date: '2018/8/9',
                    type: '申请',
                    value: 488,
                },
                {
                    date: '2018/8/10',
                    type: '下载',
                    value: 3606,
                },
                {
                    date: '2018/8/10',
                    type: '访问',
                    value: 678,
                },
                {
                    date: '2018/8/10',
                    type: '申请',
                    value: 507,
                },
                {
                    date: '2018/8/11',
                    type: '下载',
                    value: 4311,
                },
                {
                    date: '2018/8/11',
                    type: '访问',
                    value: 3188,
                },
                {
                    date: '2018/8/11',
                    type: '申请',
                    value: 548,
                },
                {
                    date: '2018/8/12',
                    type: '下载',
                    value: 4116,
                },
                {
                    date: '2018/8/12',
                    type: '访问',
                    value: 3491,
                },
                {
                    date: '2018/8/12',
                    type: '申请',
                    value: 456,
                },
                {
                    date: '2018/8/13',
                    type: '下载',
                    value: 6419,
                },
                {
                    date: '2018/8/13',
                    type: '访问',
                    value: 2852,
                },
                {
                    date: '2018/8/13',
                    type: '申请',
                    value: 689,
                },
                {
                    date: '2018/8/14',
                    type: '下载',
                    value: 1643,
                },
                {
                    date: '2018/8/14',
                    type: '访问',
                    value: 4788,
                },
                {
                    date: '2018/8/14',
                    type: '申请',
                    value: 280,
                },
                {
                    date: '2018/8/15',
                    type: '下载',
                    value: 445,
                },
                {
                    date: '2018/8/15',
                    type: '访问',
                    value: 4319,
                },
                {
                    date: '2018/8/15',
                    type: '申请',
                    value: 176,
                },
            ],
        });
    },
    'GET /mockApi/fake_apply_list_data': (_: Request, res: Response) => {
        return res.json({
            data: [
                {
                    title: '一年之计，莫如树谷；十年之计，莫如树木；百年之计，莫如树人',
                    applyUser: '管于',
                    applyDt: '2021-09-08 12:22:22',
                    state: '待审批',
                },
                {
                    title: '知识就是力量',
                    applyUser: '培根',
                    applyDt: '2021-09-08 12:22:22',
                    state: '待审批',
                },
                {
                    title: '新沐者必弹冠，新浴者必振衣',
                    applyUser: '屈原',
                    applyDt: '2021-09-08 12:22:22',
                    state: '待审批',
                },
                {
                    title: '岁寒，然后知松柏之后凋也',
                    applyUser: '孔子',
                    applyDt: '2021-09-08 12:22:22',
                    state: '待审批',
                },
                {
                    title: '天才不会毁于他人，只会毁于自己',
                    applyUser: '博斯维尔',
                    applyDt: '2021-09-08 12:22:22',
                    state: '待审批',
                },
                {
                    title: '亦余心之所善兮，虽九死其犹未悔',
                    applyUser: '屈原',
                    applyDt: '2021-09-08 12:22:22',
                    state: '待审批',
                },
                {
                    title: '先天下之忧而忧，后天下之乐而乐',
                    applyUser: '范仲淹',
                    applyDt: '2021-09-08 12:22:22',
                    state: '待审批',
                },
                {
                    title: '小荷才露尖尖角，早有蜻蜓立上头',
                    applyUser: '杨万里',
                    applyDt: '2021-09-08 12:22:22',
                    state: '待审批',
                },
                {
                    title: '知无不言，言无不尽',
                    applyUser: '苏洵',
                    applyDt: '2021-09-08 12:22:22',
                    state: '已通过',
                },
                {
                    title: '胜利不是战胜敌人，而是提高自己。我们只要每天进步百分之一，那就是成功',
                    applyUser: '佚名',
                    applyDt: '2021-09-08 12:22:22',
                    state: '已拒绝',
                },
            ],
        });
    },
    'GET /mockApi/fake_knowledge_list_data': (_: Request, res: Response) => {
        return res.json({
            data: [
                {
                    title: '一年之计，莫如树谷；十年之计，莫如树木；百年之计，莫如树人',
                    lastUpdate: '2021-09-08 12:22:22',
                    state: '草稿',
                },
                {
                    title: '知识就是力量',
                    lastUpdate: '2021-09-08 12:22:22',
                    state: '草稿',
                },
                {
                    title: '新沐者必弹冠，新浴者必振衣',
                    lastUpdate: '2021-09-08 12:22:22',
                    state: '草稿',
                },
                {
                    title: '岁寒，然后知松柏之后凋也',
                    lastUpdate: '2021-09-08 12:22:22',
                    state: '草稿',
                },
                {
                    title: '天才不会毁于他人，只会毁于自己',
                    lastUpdate: '2021-09-08 12:22:22',
                    state: '草稿',
                },
                {
                    title: '亦余心之所善兮，虽九死其犹未悔',
                    lastUpdate: '2021-09-08 12:22:22',
                    state: '草稿',
                },
                {
                    title: '先天下之忧而忧，后天下之乐而乐',
                    lastUpdate: '2021-09-08 12:22:22',
                    state: '草稿',
                },
                {
                    title: '小荷才露尖尖角，早有蜻蜓立上头',
                    lastUpdate: '2021-09-08 12:22:22',
                    state: '草稿',
                },
                {
                    title: '知无不言，言无不尽',
                    lastUpdate: '2021-09-08 12:22:22',
                    state: '已发布',
                },
                {
                    title: '胜利不是战胜敌人，而是提高自己。我们只要每天进步百分之一，那就是成功',
                    lastUpdate: '2021-09-08 12:22:22',
                    state: '已关闭',
                },
            ],
        });
    },
};
